package com.li.temperature.chart;

import com.li.temperature.chart.data.DataModel;
import com.li.temperature.chart.service.PhoneStatusService;
import com.li.temperature.chart.util.ConfigA;

import android.app.Application;
import android.content.Intent;
import android.util.Log;

public class HandleDataApplication extends Application {

    private static final String TAG = HandleDataApplication.class.getSimpleName();

    @Override
    public void onCreate() {
        super.onCreate();
        DataModel.getDataModel().setContext(getApplicationContext());

        initMatrixA();

        startService(new Intent(this, PhoneStatusService.class));
    }

    private void initMatrixA() {
        int index = 0;
        for (int i = 0; i < ConfigA.MATRIX_A_10.getRowCount(); i++) {
            for (int j = 0; j < ConfigA.MATRIX_A_10.getColumnCount(); j++) {
                ConfigA.MATRIX_A_10.setAsDouble(ConfigA.F_10[index], i, j);
                Log.d(TAG, "add row :" + i + ", columns : " + j + ", value = " + ConfigA.F_10[index] + ", index = " + index);
                index++;
            }
        }
        Log.d(TAG, ConfigA.MATRIX_A_10.toString());

        index = 0;
        for (int i = 0; i < ConfigA.MATRIX_A_15.getRowCount(); i++) {
            for (int j = 0; j < ConfigA.MATRIX_A_15.getColumnCount(); j++) {
                ConfigA.MATRIX_A_15.setAsDouble(ConfigA.F_15[index], i, j);
                Log.d(TAG, "add row :" + i + ", columns : " + j + ", value = " + ConfigA.F_15[index] + ", index = " + index);
                index++;
            }
        }
        Log.d(TAG, ConfigA.MATRIX_A_15.toString());

        index = 0;
        for (int i = 0; i < ConfigA.MATRIX_A_20.getRowCount(); i++) {
            for (int j = 0; j < ConfigA.MATRIX_A_20.getColumnCount(); j++) {
                ConfigA.MATRIX_A_20.setAsDouble(ConfigA.F_20[index], i, j);
                Log.d(TAG, "add row :" + i + ", columns : " + j + ", value = " + ConfigA.F_20[index] + ", index = " + index);
                index++;
            }
        }
        Log.d(TAG, ConfigA.MATRIX_A_20.toString());
    }
}
